import { WidgetStatus } from '@metacell/geppetto-meta-client/common/layout/model';

export const MINIMIZED_PANEL = 'border_bottom';
export { WidgetStatus };

export const TOP_PANEL = 'hlsPanel';
export const TOOLS_LIST = 'tools';

export const DEFAULT_CONFIRMATION_DIALOG_MESSAGE =
  'A NetPyNE model has already been instantiated or simulated. ' +
  'Continuing with this action will use the old value of netParams and simConfig for the new model. Do you want to continue?';

export const THEMES = {
  DARK: 'gui',
  BLACK: 'guiBlack',
  LIGHT: 'guiWhite',
} as const;

export const TUTORIALS_LIST = {
  tut1: 'Tut 1: Simple cell network',
  tut2: 'Tut 2: Detailed cell network',
  tut3: 'Tut 3a: Multiscale network (low IP3)',
  tut3_ip3high: 'Tut 3b: Multiscale network (high IP3)',
  tut3_norxd: 'Tut 3c: Multiscale network (no RxD)',
} as const;

export const MODEL_STATE = {
  NOT_INSTANTIATED: 'NOT_INSTANTIATED',
  INSTANTIATED: 'INSTANTIATED',
  SIMULATED: 'SIMULATED',
} as const;

export const DEFAULT_COLOR = {
  g: 0.5,
  b: 0.6,
  r: 1,
  a: 1,
};

export const NETPYNE_COMMANDS = {
  instantiateModel: 'netpyne_geppetto.instantiateNetPyNEModelInGeppetto',
  simulateModel: 'netpyne_geppetto.simulateNetPyNEModelInGeppetto',
  importModel: 'netpyne_geppetto.importModel',
  exportModel: 'netpyne_geppetto.exportModel',
  saveModel: 'netpyne_geppetto.saveToIndexFile',
  exportHLS: 'netpyne_geppetto.exportHLS',
  plotFigure: 'netpyne_geppetto.getPlot',
  deleteParam: 'netpyne_geppetto.deleteParam',
  checkAvailablePlots: 'netpyne_geppetto.checkAvailablePlots',
  getExperiments: 'netpyne_geppetto.experiments.get_experiments',
  cloneExperiment: 'netpyne_geppetto.cloneExperiment',
  viewExperimentResults: 'netpyne_geppetto.viewExperimentResult',
  importNeuroML: 'netpyne_geppetto.importNeuroML',
  importLEMS: 'netpyne_geppetto.importLEMS',
} as const;

export const REAL_TYPE = {
  INT: 'int',
  FLOAT: 'float',
  BOOL: 'bool',
  STR: 'str',
  FUNC: 'func',
  DICT: 'dict',
  DICT_DICT: 'dict(dict)',
} as const;

export const PYTHON_CONSOLE_WIDGET = {
  id: 'python',
  name: 'Python',
  status: WidgetStatus.MINIMIZED,
  component: 'PythonConsole',
  panelName: MINIMIZED_PANEL,
  defaultWeight: 30,
  defaultPosition: 'BOTTOM',
  defaultPanel: 'consolePanel',
  enableClose: true,
  enableDrag: true,
  enableRename: false,
  hideOnClose: true,
  pos: 1000,
  specification: TOOLS_LIST,
};

export const TOPBAR_CONSTANTS = {
  LOAD: 'LOAD',
  LOAD_INDEX: 'LOAD_INDEX',
  LOAD_INDEX_WORKSPACE: 'LOAD_INDEX_WORKSPACE',
  SAVE_INDEX_WORKSPACE: 'SAVE_INDEX_WORKSPACE',
  SAVE: 'SAVE',
  IMPORT_HLS: 'IMPORT_HLS',
  EXPORT_HLS: 'EXPORT_HLS',
  IMPORT_CELL_TEMPLATE: 'IMPORT_CELL_TEMPLATE',
  NEW_MODEL: 'NEW_MODEL',
  UPLOAD_FILES: 'UPLOAD_FILES',
  DOWNLOAD_FILES: 'DOWNLOAD_FILES',
  CREATE_NETWORK: 'Create network',
  CREATE_AND_SIMULATE_NETWORK: 'Create and simulate network',
  SIMULATE: 'Simulate network',
  EXPLORE_EXISTING_NETWORK: 'Explore model',
  BACK_TO_EDITION: 'BACK TO EDIT',
  NEW_PAGE: 'NEW_PAGE',
  NETWORK_MODEL: 'NETWORK_MODEL',
  IMPORT_NEUROML: 'IMPORT_NEUROML',
  IMPORT_LEMS: 'IMPORT_LEMS',
} as const;

export const EXPERIMENT_STATE = {
  DESIGN: 'DESIGN',
  PENDING: 'PENDING',
  SIMULATING: 'SIMULATING',
  SIMULATED: 'SIMULATED',
  INSTANTIATING: 'INSTANTIATING',
  INSTANTIATED: 'INSTANTIATED',
  ERROR: 'ERROR',
} as const;

export const SIDEBAR_HEADINGS = {
  MODEL: 'Model Specification',
  TOOLS: 'Tools',
  PLOTS: 'Plots',
} as const;

export const EXPERIMENT_TEXTS = {
  CREATE_EXPERIMENT: 'Create New Experiment',
  DELETE_EXPERIMENT: 'Delete Experiment',
  CLONE_EXPERIMENT: 'Clone Experiment',
  DIALOG_MESSAGE: 'A NetPyNE model has already been instantiated or simulated. Continuing with this action will use the old value of netParams and simConfig for the new model. Do you want to continue?',
  DELETE_DIALOG_MESSAGE: 'Are you sure you want to delete this experiment?',
  CLONE_EXPERIMENT_MESSAGE: 'This will clone the experiment. Do you want to continue?',
  RANGE: 'range',
  LIST: 'list',
  WARNING: 'Warning: This will override any existing parameter selections. Do you want to continue?',
  ERROR_EXPERIMENT_EMPTY: 'Experiment name cannot be empty',
  ERROR_EXPERIMENT_WITH_NAME_EXISTS: 'An experiment with this name already exists',
  VIEW_EXPERIMENTS_RESULTS: 'View Experiment Results',
  VIEW_EXPERIMENTS_RESULTS_MESSAGE: 'This will open the experiment results viewer. Do you want to continue?',
  LOAD_TRIAL_MODEL_SPEC: 'Load Trial Model Specification',
  LOAD_TRIAL_MODEL_SPEC_MESSAGE: 'This will load the trial model specification into the current model. Do you want to continue?',
} as const;

export const EXPERIMENT_VIEWS = {
  list: 'list',
  viewExperiment: 'viewExperiment',
  jsonViewer: 'jsonViewer',
  edit: 'edit',
} as const;

// Dialog action types
export const PYTHON_CALL = 'PYTHON_CALL';
export const LOAD_TUTORIAL = 'LOAD_TUTORIAL';

// Launch modal constants
export const LAUNCH_MODAL = {
  title: 'What do you want to simulate ?',
  modelState: 'model',
  experimentState: 'experiment',
  actionSimulate: 'Simulate',
  defaultResource: 'Server',
  errorText: 'Please check the input',
} as const;

// Widget configurations for edit mode (High Level Specification)
export const EDIT_WIDGETS: Record<string, any> = {
  // Placeholder - will be populated by Geppetto layout manager
  // These are typically defined dynamically based on the model
};

// Widget configurations for network mode (instantiated network)
export const DEFAULT_NETWORK_WIDGETS: Record<string, any> = {
  'D3Canvas': {
    id: 'D3Canvas',
    name: '3D Canvas',
    status: WidgetStatus.ACTIVE,
    component: 'D3Canvas',
    panelName: TOP_PANEL,
    defaultWeight: 50,
    defaultPosition: 'CENTER',
    defaultPanel: TOP_PANEL,
    enableClose: false,
    enableDrag: false,
    enableRename: false,
    hideOnClose: false,
    specification: 'model',
  },
  'python': PYTHON_CONSOLE_WIDGET,
};

